package String_demo;

/**
 * String支持正则表达式方法之三:
 * String replaceAll(String regex,String str)
 * 将当前字符串中满足正则表达式的部分替换为给定内容.
 */
public class StringReplaceAllDemo {
    public static void main(String[] args) {
        /** replaceAll(,) */
        String str = "123avd132dsa456das789";
        str = str.replaceAll("[0-9]+","我是");
        System.out.println(str);

        str = str.replaceAll("[a-z]+","咸蛋超人");
        System.out.println(str);

        /**  */
        String regex = "dsc|hp|cbz|xcl|wrsndm|cnm|ennmm|tmd|nybb|ngcz";
        String message = "wrsndm！你tmd!你nybb!";
        message = message.replaceAll(regex,"******");
        System.out.println(message.length());
        System.out.println(message);

    }
}
